const mgModel = require('../model/managerModel.js');

module.exports.getMgByPage = (req,res) =>{
	mgModel.getMgByPage().then(result =>{
		if(result.length ==0){
			res.send({
				mata:{
					msg:'暂时还没用户',
					status:402
				}
			})
		}else{
			let managers = [];
			for(i in result){
				let manage = result[i];
				managers.push({
					mg_id: manage.mg_id,
					mg_name:manage.mg_name,
					mg_pwd:manage.mg_pwd,
					mg_time:manage.mg_time,
					role_id:manage.role_id,
					mg_mobile:manage.mg_mobile,
					mg_email:manage.mg_email,
					mg_state:manage.mg_state
				})
			}
			res.send({
				data:managers,
				meta:{
					msg:'用户列表获取成功',
					status:200
				}
			})
		}
	}).catch({
		meta:{
		msg:'用户列表获取失败',
		status:500
		}
	})
}